package variableparameter;

//定义一个方法求n个数的和 可变参数

public class Demo1 {
    public static void main(String[] args) {
        int sum1 = getSum(1, 2, 3, 4, 12);
        System.out.println(sum1);
    }
    public static int getSum(int...arr){
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        return sum;
    }
}
